package cn.hlyc.feign;

import cn.hlyc.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeign> {
    @Override
    public UserFeign create(Throwable throwable) {
        return new UserFeign() {
            @Override
            public User getUserById(long userid) {
                //把异常信息打印到控制台
                throwable.printStackTrace();

                //真正拖地方法 ， 这里的数据是托底数据
                return new User(-1L,"无此用户","用户服务不可用");
            }
        };
    }
}
